package com.ruoyi.client.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.minio.properties.MinioProperties;
import com.ruoyi.common.minio.utils.MinioUtils;
import com.ruoyi.common.web.core.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("client/user/file")
public class FileController extends BaseController {
    @Autowired
    MinioUtils minioUtils;
    @Autowired
    MinioProperties properties;
    @PostMapping(value = "upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<String> upload(@RequestPart("file") MultipartFile file){
        String path = minioUtils.uploadFileByMultipartFile(file);
        return R.ok("ok",path);
    }
    @SaIgnore
    @PostMapping("upload2")
    public R upload2(){
        System.out.println(properties);
        return R.ok();
    }
}
